package com.vanke.devops.api.controller.docker;

import com.vanke.core.bean.ApiBaseResponse;
import com.vanke.core.bean.PagingResponse;
import com.vanke.devops.api.base.AbstractController;
import com.vanke.devops.api.base.BaseController;
import com.vanke.devops.api.controller.docker.form.SwarmClusterForm;
import com.vanke.devops.dal.model.SwarmCluster;
import com.vanke.devops.domain.domain.docker.ISwarmClusterService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表  前端控制器
 * </p>
 *
 * @author 陈景阳
 * @since 2018-06-07
 */
@RestController
@RequestMapping("/swarm-cluster")
public class SwarmClusterController extends AbstractController<ISwarmClusterService> {

    @GetMapping(value = "/list")
    public ApiBaseResponse list()  {
        return setResponse(service.list());
    }

    @GetMapping(value = "/{id}")
    public ApiBaseResponse get(@PathVariable("id") Integer id)  {
        return setResponse(service.getInfo(id));
    }


    @DeleteMapping(value = "/{id}")
    public ApiBaseResponse delete(@PathVariable("id") Integer id)  {
        service.delete(id);
        return setResponse();
    }

    @PostMapping
    public ApiBaseResponse add(@RequestBody SwarmClusterForm form)  {
        return setResponse(service.add(form.getName(),form.getLeader(),form.getRemark()));
    }
}